package Day10;

import java.util.*;
// 1:无需package
// 2: 类名必须Main, 不可修改
/**
 * 2021Java真题:路径
 * https://www.lanqiao.cn/problems/1460/learning/
 */
public class Main3 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int[] dp = new int[2022];
        dp[1] = 0;
        for(int i = 2; i <= 2021; i++){
          dp[i]= Integer.MAX_VALUE ;
        }

        for(int i = 1; i <= 2020; i++){
          for(int j = i + 1; j <= 2021; j++){
            if(j - i <= 21){
              dp[j] = Math.min(dp[j] ,dp[i] + lcm(i , j));
            }
          }
        }
        System.out.println(dp[2021]);
        scan.close();
    }

    public static int gcd(int x , int y){
      while(x % y != 0){
        int c = x % y;
        x = y;
        y = c;
      }
      return y;
    }

    public static int lcm(int x , int y){
      return x * y / gcd(x , y);
    }
}